import React, { useContext } from 'react'
import context from '../context'

function Com () {
  // 子组件中直接通过context拿到dispatch，出发reducer操作state
  const { dispatch, state } = useContext(context)
  return (<p>组件1。修改age.<button onClick={() => { dispatch({ type: 'age', payload: 100 }) }}>修改age, {state.age}</button></p>)
}

export default Com
